/**  
* @author: suan@unibroad.com
* @date 2014�?5�?6�? 下午6:40:36
* @Copyright: 2014 unibroad.com Inc. All rights reserved.
*/
package com.strugglerz.model.common;

import java.io.Serializable;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * @Title: BaseResult.java
 * @Package com.unibroad.appstore.web.base
 * @Description: 通用操作结果
 * @version V1.0
 */
public class BaseResult<T> implements Serializable {

	/**
     * <code>serialVersionUID</code> - {成员变量描述}.
     */
    private static final long serialVersionUID = 7549433369785226497L;

    /** 操作是否是成功 */
    @JSONField(ordinal = 0)
    private boolean success;

    /** 操作信息提示 */
    @JSONField(ordinal = 1)
    private String message;

    /** 实现数据 */
    @JSONField(ordinal = 2)
    private T data;

    /**
     * 构造函数.
     * 
     * @param success
     */
    public BaseResult(boolean success) {
        super();
        this.success = success;
    }

    /**
     * 构造函数.
     * 
     * @param success
     * @param message
     */
    public BaseResult(boolean success, String message) {
        super();
        this.success = success;
        this.message = message;
    }

    /**
     * {方法描述}.
     * 
     * @param success
     * @param message
     * @param data
     */
    public BaseResult<T> setResult(boolean success, String message, T data) {
        this.setSuccess(success);
        this.setData(data);
        this.setMessage(message);
        return this;
    }

    /**
     * @return the success - {返回值描述信息}.
     */
    public boolean isSuccess() {
        return success;
    }

    /**
     * @param success
     *            - {参数含义描述}.
     */
    public BaseResult<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    /**
     * @return the message - {返回值描述信息}.
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param message
     *            - {参数含义描述}.
     */
    public BaseResult<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    /**
     * @return the data - {返回值描述信息}.
     */
    public T getData() {
        return data;
    }

    /**
     * @param data
     *            - {参数含义描述}.
     */
    public BaseResult<T> setData(T data) {
        this.data = data;
        return this;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "success=" + success + ",message=" + message + ",data=" + data;
    }

}
